package org.msb.accentis.data.pojo;

import java.math.BigDecimal;
import java.util.Currency;

import javax.persistence.Basic;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.Lob;
//import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;

import org.msb.accentis.data.AccountType;

@Entity
@NamedQueries({ @NamedQuery(name = "Account.getAllAccounts", query = "SELECT a FROM Account a ORDER BY a.name"),
		@NamedQuery(name = "Account.getAccountById", query = "SELECT a FROM Account a WHERE a.id = :accountId"),
		@NamedQuery(name = "Account.getAllAccountsForType", query = "SELECT a FROM Account a WHERE a.accountType = :type ORDER BY a.name"),
		@NamedQuery(name = "Account.getAllAccountsReferencingInstitution", query = "SELECT a FROM Account a WHERE a.institution = :institution") })
public class Account extends NamedObject {

	@Enumerated(EnumType.ORDINAL)
	private AccountType accountType;

	@Basic
	private BigDecimal startingBalance;

	@Basic
	private BigDecimal minimumBalance;

	@Basic
	private String accountNumber;

	@Basic
	private Currency accountCurrency;

//	@ManyToOne
//	private Institution institution;

	@Basic
	private boolean closed;

	@Lob
	private String description;

	public Account() {
		this(AccountType.BANK);
	}

	public Account(AccountType type) {
		accountType = type;
	}

	public Account(String name) {
		super(name);
	}

	public Account(String name, AccountType type) {
		super(name);
		accountType = type;
	}

	public AccountType getAccountType() {
		return accountType;
	}

	public void setAccountType(AccountType value) {
		accountType = value;
	}

	public BigDecimal getStartingBalance() {
		return startingBalance;
	}

	public void setStartingBalance(BigDecimal value) {
		startingBalance = value;
	}

	public BigDecimal getMinimumBalance() {
		return minimumBalance;
	}

	public void setMinimumBalance(BigDecimal value) {
		minimumBalance = value;
	}

	public String getNumber() {
		return accountNumber;
	}

	public void setNumber(String value) {
		accountNumber = value;
	}

//	public Institution getInstitution() {
//		return institution;
//	}
//
//	public void setInstitution(Institution value) {
//		institution = value;
//	}

	public Currency getCurrency() {
		return accountCurrency;
	}

	public void setCurrency(Currency currency) {
		accountCurrency = currency;
	}

	public boolean isClosed() {
		return closed;
	}

	public void setClosed(boolean value) {
		closed = value;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String value) {
		description = value;
	}
}
